/**
 * 
 */
package sismed.gui.comando;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import sismed.negocio.fachada.Fachada;
import sismed.negocio.modelo.ReceitaMedica;

/**
 * @author Berg
 *
 */
public class ComandoAdministrarMedicamentos extends ComandoGenerico {

	/* (non-Javadoc)
	 * @see sismed.gui.comando.ComandoGenerico#executar(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
	 */
	@Override
	public void executar(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {

		if(request.getSession().getAttribute("tipoUsuario").equals(null))				
			response.sendRedirect("login.jsp");
		else
		{
			Fachada fachada = Fachada.getInstance();
		
			List<ReceitaMedica> lista = fachada.recuperarListaReceitaMedica();		
			
			request.setAttribute("ListaReceita", lista);
						
			try 
			{			
				request.getRequestDispatcher("administrarMedicamentos.jsp").forward(request, response);	
			} 
			catch (Exception e) 
			{
				request.getRequestDispatcher("erro.jsp").forward(request, response);	
			}
		}

	}

}
